package Game;

import java.awt.Graphics2D;


public class Level02Pong extends Scene
{
	Background BG = new Background(0,0,800,600);
	Ball ball = new Ball(400, 300, 10, 10, 5, 5);
	PlayerPong player1 = new PlayerPong(40, 300, 10, 70, false);
	PlayerPong player2 = new PlayerPong(750, 300, 10, 70, true);
	PlayerPong Barreira = new PlayerPong(400, 250, 10, 100, false);
	int Score1 = 0;
	int Score2 = 0;
	public Level02Pong()
	{
		BG.Load("/Imagens/background.png");
	}
	
	@Override
	public void update(InputManager input) 
	{
		player1.Update(input);
		player2.Update(input);
		Barreira.Update(0);
		ball.Pong(player1, player2, Barreira, new PlayerPong(-10,-10,0,0, false));
		if (ball.x < 0)
		{
			ball.x = 400;
			ball.y = 300;
			Score1++;
		}
		
		if (ball.x > 800)
		{
			ball.x = 400;
			ball.y = 300;
			Score2++;
		}
		
		if (Score1 >= 3|| Score2 >= 3)
		{
			SceneManager.MudarCena();
		}
	}
	
	@Override
	public void draw(Graphics2D g2d) 
	{
		BG.Draw(g2d);
		player1.Draw(g2d);
		player2.Draw(g2d);
		Barreira.Draw(g2d);
		ball.Draw(g2d);
	}
}
